package com.fsc.mapper;

import com.fsc.entity.domain.PictureVideo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;
/**
* @author 86183
* @description 针对表【picture_video(学生签到签退表)】的数据库操作Mapper
* @createDate 2024-06-02 13:15:22
* @Entity com.fsc.domain.PictureVideo
*/

@Mapper
public interface PictureVideoMapper extends BaseMapper<PictureVideo> {

    @Select("SELECT * FROM db01.picture_video WHERE student_id = #{studentId}")
    List<PictureVideo> getAttendanceByStudentId(int studentId);
    @Select("SELECT * FROM db01.picture_video ")
    List<PictureVideo> getAllAttendance();

    @Update("UPDATE db01.picture_video SET url = #{url} WHERE student_id = #{studentId} AND time = #{time}")
    int  updatePictureVideoUrl(@Param("studentId") int studentId, @Param("time") String time, @Param("url") String url);

    @Select("SELECT pv.* FROM db01.picture_video pv " +
            "JOIN db01.stu_part_teach spt ON pv.student_id = spt.student_id " +
            "WHERE spt.teacher_id = #{teacherId}")
    List<PictureVideo> getAttendanceByTeacherId(int teacherId);

    @Select("SELECT pv.* FROM db01.picture_video pv " +
            "JOIN db01.stu_part_teach spt ON pv.student_id = spt.student_id " +
            "WHERE spt.parent_id = #{parentId}")
    List<PictureVideo> getAttendanceByParentId(int parentId);

    @Insert("INSERT INTO picture_video (student_id, status, url, time) VALUES (#{studentId}, #{status}, #{url}, #{time})")
    void insertAttendance(@Param("studentId") int studentId, @Param("status") String status, @Param("url") String url, @Param("time") Date time);

    @Update("UPDATE picture_video SET status = #{status}, time = #{time} WHERE id = #{id}")
    void updateAttendance(@Param("id") int id, @Param("status") String status, @Param("time") Date time);

    @Delete("DELETE FROM picture_video WHERE id = #{id}")
    void deleteAttendance(@Param("id") int id);
}




